﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Shpm.App.Main.Bean;
using Shpm.App.Main.Dao;
using Shpm.System;
using Shpm.App.Commons.Db.Beans.Master;
using Shpm.App.Commons.Utils;
using Shpm.App.Input.Bean;
using Shpm.App.Input.Dao;


public partial class App_System_PortalMainForm : System.Web.UI.Page
{

    protected string prepare = string.Empty;
    protected string reside = string.Empty;
    protected string empty = string.Empty;
    protected string employeeId = string.Empty;
    protected string employeeName = string.Empty;
    protected string employeeJob = string.Empty;
    protected string employeeLev = string.Empty;
    protected string personId = string.Empty;
    protected string userId = string.Empty;

    // page constant params 
    protected Int32 refreshMsgMSeconds;
    protected Int32 msgGlitterMSeconds;
    protected Int32 msgGlitterCount;
    protected Int32 msgMaxDispCount;

    //private const int JOB_ID_DOCTOR = 31;//职位编号
    private const int JOB_ID_DOCTOR = 34;//保健医生职位编号

    protected void Page_Load(object sender, EventArgs e)
    {
        this.refreshMsgMSeconds = Constants.REFRESH_MSG_MILLI_SECONDS;
        this.msgGlitterMSeconds = Constants.MSG_GLITTER_MILLI_SECONDS;
        this.msgGlitterCount = Constants.MSG_GLITTER_COUNT;
        this.msgMaxDispCount = Constants.MAX_NEW_MSG_DISP_COUNT;

        // 查询销售过程

        SysUserManager manager = new SysUserManager(Context);
        SysUserBean sysUserBean = manager.getSysUserBean();
        if (sysUserBean == null)
        {
            return;
        }
        IList DepartList = sysUserBean.getDepartments();
        if (DepartList.Count > 0)
        {
            MstDepartmentBean dtBean = (MstDepartmentBean)DepartList[0];
            Context.Items["DEPART_ID"] = dtBean.DepartId;
        }
        else
        {
            Context.Items["DEPART_ID"] = null;
        }
        if (sysUserBean != null)
        {
            MstEmployeeBean empBean = sysUserBean.getEmployeeBean();
            MstSysUserBean mstSysUserBean =
                sysUserBean == null ? null : sysUserBean.getMstSysUserBean();
            if (mstSysUserBean != null)
            {
                this.userId = mstSysUserBean == null ? "" : mstSysUserBean.SysUserId;
            }
            if (empBean != null)
            {
                this.employeeId = empBean.EmployeeId;
                this.employeeName = empBean.EmployeeName;
                this.personId = Convert.ToString(empBean.PersonId);

                IList dataList = null;
                //查找JOB_ID

                PersonEmployeeDao personEmployeeDao = new PersonEmployeeDao();
                PersonEmployeeBean personEmployeeBean = new PersonEmployeeBean();
                personEmployeeBean.EmployeeId = empBean.EmployeeId;
                personEmployeeBean = personEmployeeDao.Find(personEmployeeBean);
                ////保健医生

                //if (JOB_ID_DOCTOR.Equals(personEmployeeBean.JobId))
                //{
                //    HealthAssignBean dataBean = new HealthAssignBean();
                //    HealthAssignDao Dao = new HealthAssignDao();
                //    dataBean.DoctorId = empBean.EmployeeId;
                //    dataList = Dao.FindByMenberHave(dataBean);
                //    Repeater1.DataSource = dataList;
                //    Repeater1.DataBind();
                //    Repeater2.Visible = false;
                //}
                //else 
                //{
                //    HappyChamberlaineBean dataBean = new HappyChamberlaineBean();
                //    HappyChamberlaineSrhDao Dao = new HappyChamberlaineSrhDao();
                //    dataBean.EmployeeId = empBean.EmployeeId;
                //    dataList = Dao.FindByMenberHave(dataBean);
                //    Repeater2.DataSource = dataList;
                //    Repeater2.DataBind();
                //    Repeater1.Visible = false;
                //}


                this.employeeJob = personEmployeeBean.JobName;
                //IList dataList = dao.FindSalesByEmployee(empBean);


            }
        }
        //boundLeft();
        //boundRight();
    }



    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
    }

    protected void LinkButton_Command(object sender, CommandEventArgs e)
    {
        // 传递控件参数
        Context.Items["MEMBER_NO"] = e.CommandArgument;

        if (e.CommandName == "Step0")
        {
            // 生活模型

            ControllerUtils.Transfer(this.Context, "~/App/Input/LivingMemberLivingForm.aspx", true);
        }

    }

    //private void boundLeft()
    //{
    //    HappyPlanDao dao = new HappyPlanDao();
    //    HappyPlanBean beanHP = new HappyPlanBean();
    //    IList dataList = dao.ListHappyPlanLeft(beanHP);

    //    if (dataList.Count > 0)
    //    {
    //        IEnumerator enm = dataList.GetEnumerator();
    //        while (enm.MoveNext())
    //        {
    //            beanHP = (HappyPlanBean)enm.Current;
    //            TableRow tblRow = new TableRow();
    //            TableCell tblCell;
    //            LinkButton lbtnName = new LinkButton();
    //            tblCell = new TableCell();
    //            lbtnName.Text = beanHP.ActionName;
    //            lbtnName.CommandArgument = Convert.ToString(beanHP.ActionId);
    //            lbtnName.Command += new CommandEventHandler(this.LinkButton_Command_Left);
    //            tblCell.Controls.Add(lbtnName);
    //            tblRow.Cells.Add(tblCell);
    //            TblItem.Rows.Add(tblRow);
    //        }
    //    }
    //}
    //private void boundRight()
    //{
    //    HappyPlanDao dao = new HappyPlanDao();
    //    HappyPlanBean beanHP = new HappyPlanBean();
    //    IList dataList = dao.ListHappyPlanRight(beanHP);

    //    if (dataList.Count > 0)
    //    {
    //        IEnumerator enm = dataList.GetEnumerator();
    //        while (enm.MoveNext())
    //        {
    //            beanHP = (HappyPlanBean)enm.Current;
    //            TableRow tblRow = new TableRow();
    //            TableCell tblCell;
    //            LinkButton lbtnName = new LinkButton();
    //            tblCell = new TableCell();
    //            lbtnName.Text = beanHP.ActionName;
    //            lbtnName.CommandArgument = Convert.ToString(beanHP.ActionId);
    //            lbtnName.Command += new CommandEventHandler(this.LinkButton_Command_Right);
    //            tblCell.Controls.Add(lbtnName);
    //            tblRow.Cells.Add(tblCell);
    //            TblItem2.Rows.Add(tblRow);
    //        }
    //    }
    //}
    //protected void LinkButton_Command_Left(object sender, CommandEventArgs e)
    //{

    //    string directUrl;
    //    Context.Items["ACTION_ID"] = e.CommandArgument;
    //    directUrl = "~/App/Input/HappyIntentUpdForm.aspx";
    //    Context.Items["InpActName"] = "";
    //    Context.Items["InpActType"] = "";
    //    Context.Items["InpActStat1"] = "";
    //    Context.Items["InpActStat2"] = "";
    //    Context.Items["InpBeginDate"] = "";
    //    Context.Items["InpEndDate"] = "";
    //    ControllerUtils.Transfer(this.Context, directUrl, true);
    //}
    //protected void LinkButton_Command_Right(object sender, CommandEventArgs e)
    //{

    //    string directUrl;
    //    Context.Items["ACTION_ID"] = e.CommandArgument;
    //    directUrl = "~/App/Input/HappyEvaluateUpdForm.aspx";
    //    Context.Items["InpActName"] = "";
    //    Context.Items["InpActType"] = "";
    //    Context.Items["InpActStat1"] = "";
    //    Context.Items["InpActStat2"] = "";
    //    Context.Items["InpBeginDate"] = "";
    //    Context.Items["InpEndDate"] = "";
    //    ControllerUtils.Transfer(this.Context, directUrl, true);
    //}


}
